<% @chapter = chapter if defined?(chapter) %>
<div class="meta">
  <% unless @mobi %><h2><%= @chapter.chapter_title %></h2><% end %>
  <% if (!@chapter.pseuds.blank? && (@chapter.pseuds != @work.pseuds)) %>
    <!-- only display byline if different from the main byline -->
    <p class="byline"><%= ts('Chapter by') %> <%= byline(@chapter) %></p>
  <% end %>

  <% unless @chapter.summary.blank? %>
    <p><%= ts('Chapter Summary') %></p>
    <blockquote class="userstuff"><%=raw sanitize_field(@chapter, :summary) %></blockquote>
  <% end %>
  
  <% unless @chapter.notes.blank? && @chapter.endnotes.blank? %>
    <p><%= ts('Chapter Notes') %></p>
    <% unless @chapter.notes.blank? %>
      <blockquote class="userstuff"><%=raw sanitize_field(@chapter, :notes) %></blockquote>
    <% end %>
    <% unless @chapter.endnotes.blank? %>
      <div class="endnote-link">
        <%= ts("See the end of the chapter for") %> <% unless @chapter.notes.blank? %><%= ts("more") %><% end %> <%= link_to ts("notes"), "#endnotes#{@chapter.position}" %>
      </div>
    <% end %> 
  <% end %>
</div>

<!--chapter content-->
<div class="userstuff">
  <%=raw sanitize_field(@chapter, :content) %>
</div>
<!--/chapter content-->

<% unless @chapter.endnotes.blank? %>
  <div class="meta" id="endnotes<%= @chapter.position %>">
    <p><%= ts('Chapter End Notes') %></p>
    <blockquote class="userstuff"><%=raw sanitize_field(@chapter, :endnotes) %></blockquote>
  </div>
<% end %>
